package com.jwthhealth_pub.old.report.view.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jwthhealth_pub.R;
import com.jwthhealth_pub.old.report.model.resbody.EnviDescResp;
import com.jwthhealth_pub.old.report.view.IndicalEnvironmentActivity;

import java.util.List;

/**
 * 内环境指标说明
 * Created by liuzhen on 2017/10/30.
 */

public class EnviIndiAdapter extends RecyclerView.Adapter {
    private final IndicalEnvironmentActivity mActivity;
    private final List<EnviDescResp.DataBean.SonBean> mData;

    public EnviIndiAdapter(IndicalEnvironmentActivity indicalEnvironmentActivity, List<EnviDescResp.DataBean.SonBean> mData) {
        this.mActivity = indicalEnvironmentActivity;
        this.mData = mData;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        return new ViewHolder(View.inflate(mActivity, R.layout.item_phys_stat_desc, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ViewHolder vh = (ViewHolder) holder;

        EnviDescResp.DataBean.SonBean sonBean = mData.get(vh.getAdapterPosition());

        vh.tvKey.setText(sonBean.getTitle());
        vh.tvValue.setText(sonBean.getValue());
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }

    private class ViewHolder extends RecyclerView.ViewHolder {

        TextView tvKey, tvValue;

        public ViewHolder(View itemView) {
            super(itemView);
            tvKey = itemView.findViewById(R.id.tv_key);
            tvValue = itemView.findViewById(R.id.tv_value);
        }
    }
}
